﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using Stile.Patterns.Disposables;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.Specifications.Delta
{
	public class PreconditionEvaluation<TEvaluation> : Disposable,
		IPreconditionEvaluation
		where TEvaluation : class, IEvaluation
	{
		private IEvaluable<TEvaluation> _postcondition;

		public PreconditionEvaluation(TEvaluation evaluation, IEvaluable<TEvaluation> postcondition)
		{
			_postcondition = postcondition;
			Evaluation = evaluation;
		}

		public IEvaluation Evaluation { get; private set; }

		public IEvaluable<IEvaluation> GetPostcondition()
		{
			RequireNotAlreadyDisposed();
			return _postcondition;
		}

		protected override void Disposing()
		{
			_postcondition = null;
			Evaluation = null;
		}
	}
}
